package com.zc.custom.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.custom.domain.ChargeCustomOrderInfoDetails;
import com.zc.custom.service.IChargeCustomOrderInfoDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单计费详情Controller
 * 
 * @author glb
 * @date 2023-11-15
 */
@RestController
@RequestMapping("/custom/details")
public class ChargeCustomOrderInfoDetailsController extends BaseController
{
    @Autowired
    private IChargeCustomOrderInfoDetailsService chargeCustomOrderInfoDetailsService;

    /**
     * 查询订单计费详情列表
     */
    @PreAuthorize("@ss.hasPermi('custom:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeCustomOrderInfoDetails chargeCustomOrderInfoDetails)
    {
        startPage();
        List<ChargeCustomOrderInfoDetails> list = chargeCustomOrderInfoDetailsService.selectChargeCustomOrderInfoDetailsList(chargeCustomOrderInfoDetails);
        return getDataTable(list);
    }

    /**
     * 导出订单计费详情列表
     */
    @PreAuthorize("@ss.hasPermi('custom:details:export')")
    @Log(title = "订单计费详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeCustomOrderInfoDetails chargeCustomOrderInfoDetails)
    {
        List<ChargeCustomOrderInfoDetails> list = chargeCustomOrderInfoDetailsService.selectChargeCustomOrderInfoDetailsList(chargeCustomOrderInfoDetails);
        ExcelUtil<ChargeCustomOrderInfoDetails> util = new ExcelUtil<>(ChargeCustomOrderInfoDetails.class);
        util.exportExcel(response, list, "订单计费详情数据");
    }

    /**
     * 获取订单计费详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('custom:details:query')")
    @GetMapping(value = "/{orderInfoDetailsId}")
    public AjaxResult getInfo(@PathVariable("orderInfoDetailsId") Long orderInfoDetailsId)
    {
        return AjaxResult.success(chargeCustomOrderInfoDetailsService.selectChargeCustomOrderInfoDetailsByOrderInfoDetailsId(orderInfoDetailsId));
    }

    /**
     * 新增订单计费详情
     */
    @PreAuthorize("@ss.hasPermi('custom:details:add')")
    @Log(title = "订单计费详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeCustomOrderInfoDetails chargeCustomOrderInfoDetails)
    {
        return toAjax(chargeCustomOrderInfoDetailsService.insertChargeCustomOrderInfoDetails(chargeCustomOrderInfoDetails));
    }

    /**
     * 修改订单计费详情
     */
    @PreAuthorize("@ss.hasPermi('custom:details:edit')")
    @Log(title = "订单计费详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeCustomOrderInfoDetails chargeCustomOrderInfoDetails)
    {
        return toAjax(chargeCustomOrderInfoDetailsService.updateChargeCustomOrderInfoDetails(chargeCustomOrderInfoDetails));
    }

    /**
     * 删除订单计费详情
     */
    @PreAuthorize("@ss.hasPermi('custom:details:remove')")
    @Log(title = "订单计费详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderInfoDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] orderInfoDetailsIds)
    {
        return toAjax(chargeCustomOrderInfoDetailsService.deleteChargeCustomOrderInfoDetailsByOrderInfoDetailsIds(orderInfoDetailsIds));
    }
}
